package com.example.demo.controller;

import com.example.demo.common.BasePageResponse;
import com.example.demo.common.ResultObject;
import com.example.demo.jooq.tables.pojos.Account;
import com.example.demo.jooq.tables.pojos.Address;
import com.example.demo.model.request.AccountPageRequest;
import com.example.demo.model.request.AccountRequest;
import com.example.demo.model.response.AccountPageResponse;
import com.example.demo.service.order.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("v1/account/")
public class AccountController {

    @Autowired
    private IAccountService iAccountService;
    @GetMapping(value = "list")
    public ResultObject<BasePageResponse<AccountPageResponse>> queryPageAccountList(AccountPageRequest accountPageRequest) {
        return iAccountService.queryPageAccountList(accountPageRequest);
    }

    /**
     * 账户保存
     * @param account 数据对象
     * @return
     */
    @PostMapping(value = "save")
    public ResultObject  saveAddress(@RequestBody AccountRequest account) {
        return iAccountService.saveAccount(account);
    }

    /**
     * 账户详细查询
     * @param accountId 数据对象
     * @return
     */
    @GetMapping(value = "detail")
    public ResultObject  saveAddress(@RequestParam("accountId") String accountId) {
        return iAccountService.queryAccountDetail(accountId);
    }
}
